package com.yipei.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yipei.common.annotation.Log;
import com.yipei.common.core.controller.BaseController;
import com.yipei.common.core.domain.AjaxResult;
import com.yipei.common.enums.BusinessType;
import com.yipei.business.domain.MlHoliday;
import com.yipei.business.service.IMlHolidayService;
import com.yipei.common.utils.poi.ExcelUtil;
import com.yipei.common.core.page.TableDataInfo;

/**
 * 节日表Controller
 * 
 * @author yipei
 * @date 2025-01-22
 */
@RestController
@RequestMapping("/business/holiday")
public class MlHolidayController extends BaseController
{
    @Autowired
    private IMlHolidayService mlHolidayService;

    /**
     * 查询节日表列表
     */
    @PreAuthorize("@ss.hasPermi('business:holiday:list')")
    @GetMapping("/list")
    public TableDataInfo list(MlHoliday mlHoliday)
    {
        startPage();
        List<MlHoliday> list = mlHolidayService.selectMlHolidayList(mlHoliday);
        return getDataTable(list);
    }

    /**
     * 导出节日表列表
     */
    @PreAuthorize("@ss.hasPermi('business:holiday:export')")
    @Log(title = "节日表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MlHoliday mlHoliday)
    {
        List<MlHoliday> list = mlHolidayService.selectMlHolidayList(mlHoliday);
        ExcelUtil<MlHoliday> util = new ExcelUtil<MlHoliday>(MlHoliday.class);
        util.exportExcel(response, list, "节日表数据");
    }

    /**
     * 获取节日表详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:holiday:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(mlHolidayService.selectMlHolidayById(id));
    }

    /**
     * 新增节日表
     */
    @PreAuthorize("@ss.hasPermi('business:holiday:add')")
    @Log(title = "节日表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MlHoliday mlHoliday)
    {
        return toAjax(mlHolidayService.insertMlHoliday(mlHoliday));
    }

    /**
     * 修改节日表
     */
    @PreAuthorize("@ss.hasPermi('business:holiday:edit')")
    @Log(title = "节日表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MlHoliday mlHoliday)
    {
        return toAjax(mlHolidayService.updateMlHoliday(mlHoliday));
    }

    /**
     * 删除节日表
     */
    @PreAuthorize("@ss.hasPermi('business:holiday:remove')")
    @Log(title = "节日表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(mlHolidayService.deleteMlHolidayByIds(ids));
    }
}
